perm filename FOO.PUB[LSP,JRA]13 blob
sn#352514 filedate 1978-05-03 generic text, type T, neo UTF8
.BEGIN TURN ON "←";
Now to the problem of translating a %3prog%* into an S-expression representation:
the construct,
.BOXA
←%3prog[[v%41%3; ...; v%4n%3] ... ]%1 will be translated to:
.PT2
←%3(PROG(V1 ... VN) ... )%*
.BOXB
.FP
The body of the %3prog%* must be handled specially by a
new piece of the evaluator since
%3prog%* is a special form.
.TURN OFF "←";
.begin turn on "#";
We must also be careful about the interpretation of ←.
We will write %3x#←#y%* in prefix form as: %3setq[x;y]%*.
We will map this to:
.end
.BEGIN CENTER
.BOXA
%3(SETQ X Y) %*
.END
.FP
The assignment,
%3setq%1, is also a special form.
For if %3x%* and %3y%* have values %32%* and %33%*, for example, then the
call-by-value interpretation of %3setq[x;y]%* would say %3setq[2;3]%*. This was not our
intention. We want to evaluate the second argument
to %3setq%1 while stopping the evaluation of the first argument.
LISP has another assignment-like operator called %3set%1.
Both arguments of this binary operator are evaluated; the value
of the first argument is expected to be a representation of a variable;
that is, the first argument evaluates to a literal atom.
The second argument is a LISP form
and using the value of that form, an assignment is made to the
variable represented by the first argument. Thus
%3setq[x;y]%1 is synonymous with %3set[quote[x];y]%1.
.TURN ON "←";
As a more complex example, consider %3set[z; plus[x;1]]%1.
If the current value of
variable %3z%* is an identifier, then
%3set[z; plus[x;1]]%* makes sense. Assume the current value of
%3z%1 is %3A%*; and assume the current value of %3x%1 is %32%1;
since %3A%1 represents the identifier %3a%1,
the effect of the %3set%* statement is to assign the value %33%* to %3a%*.
Normally when making assignments, we want to assign to a %6name%* and
not a %6value%*; thus we will tend to use the %3setq%1 form.
.GROUP
Finally, here is a translation of the body of the %3prog%* version of %3length:%*
.P250:
%3
.BEGIN TABIT3(7,20,24);
.BOXA
\(LAMBDA\(L)
\\(PROG (L1 C)
\\\(SETQ L1 L)
\\\(SETQ C 0)
\\A\(COND ((NULL L1) (RETURN C)))
\\\(SETQ C (ADD1 C))
\\\(SETQ L1 (REST L1))
\\\(GO A) ))
.BOXB
.END
.APART
%1
.END